package com.tanhua.management.service;


import com.alibaba.dubbo.config.annotation.Reference;
import com.tanhua.common.pojo.Log;
import com.tanhua.management.api.LogApi;
import com.tanhua.management.vo.LogVo;
import com.tanhua.server.vo.PageResult;
import org.springframework.stereotype.Service;

import java.lang.reflect.Type;
import java.util.ArrayList;
import java.util.List;

/**
 * Create By Administrator on 2021/7/14.
 */
@Service
public class LogService {

     @Reference
    private LogApi logApi;


    public PageResult queryLogsList(Type type, Integer page, Integer pageSize) {

        PageResult pageResult = new PageResult();
        pageResult.setPage(page);
        pageResult.setPagesize(pageSize);

        List<Log> records = logApi.queryLogsList(type, page, pageSize).getRecords();

        List<LogVo> logVos = new ArrayList<>();
        records.forEach(log -> {
            LogVo LogVo = new LogVo();
            LogVo.setId(log.getId().intValue()+900000);
            LogVo.setLongTime(Integer.parseInt(log.getLogTime()));
            LogVo.setEquipment(log.getEquipment());
            LogVo.setPlace(log.getPlace());
            logVos.add(LogVo);
        });
        return pageResult;
    }
}
